﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace OpenQuarters.WebQuarters.Core
{
    public class ActionPermissionAttribute : ActionFilterAttribute
    {
        public string Role { get; set; }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            if (!User.Current.HasRole(Role))
                filterContext.Result = new RedirectResult("~/site/" + CMSPage.LoginPage.Urls[0].PageUrl);
        }
    }
}
